import request from '../utils/request';
//项目全部的接口在这里统一管理
//获取banner
export const reqBanner = () => request({
    url: "/mall-api/index/findBanner"
});
//获取首页分类的数据
export const reqCategory = () => request({
    url: '/mall-api/index/findCategory1'
});
//猜你喜欢的接口
export const reqLike = () => request({
    url: '/mall-api/index/findListGoods'
});

//热门推荐
export const reqHot = () => request({
    url: `/mall-api/index/findRecommendGoods`
})


//获取分类模块的数据
export const reqSort = () => request({
    url: `/mall-api/index/findCategoryTree`
})

//获取用户授权登录成功用户唯一标识token
export const reqToken = (code) => request({
    url: `/mall-api/weixin/wxLogin/${code}`
})

//获取用户信息接口
export const reqUserInfo = () => request({
    url: `/mall-api/weixin/getuserInfo`
});


//更新用户信息的接口
export const reqUpdateInfo = (data) => request({
    url: `/mall-api/weixin/updateUser`,
    method: 'post',
    data
});

//获取商品列表的接口
export const reqGoodsList = (page, limit, category2Id) => request({
    url: `/mall-api/goods/list/${page}/${limit}?category2Id=${category2Id}`
})

//获取用户购物车的数据
export const reqCart = () => request({
    url: `/mall-api/cart/getCartList`
});

//更新用户的商品的勾选的状态
export const reqUpdateChecked = (goodsId, isChecked) => request({
    url: `/mall-api/cart/checkCart/${goodsId}/${isChecked}`
})

//删除商品
export const reqDeleteGood = (goodsId) => request({
    url: `/mall-api/cart/delete/${goodsId}`
});

//此接口可以加入购物车|修改购物车某一个商品的数量
export const reqAddOrUpdateCart = (goodsId, count, blessing) => request({
    url: `/mall-api/cart/addToCart/${goodsId}/${count}?blessing=${blessing}`
});


//获取商品的详情数据
export const reqGoodsDetail = (goodsId) => request({
    url: `/mall-api/goods/${goodsId}`
})

//获取订单详情页-立即购买的商品的信息
export const reqBuyNowGoodsInfo = (goodsId, blessing) => request({
    url: `/mall-api/order/buy/${goodsId}?blessing=${blessing}`
})

//获取订单收货人地址信息
export const reqAdress = () => request({
    url: `/mall-api/userAddress/getOrderAddress`
})

//提交订单的接口
export const reqSubmit = (data) => request({
    url: `/mall-api/order/submitOrder`,
    method: "POST",
    data
})

//获取支付参数接口
export const reqPayInfo = (orderNo) => request({
    url: `/mall-api/webChat/createJsapi/${orderNo}`
});


//支付结果的查询
export const reqPayStatus = (orderNo) => request({
    url: `/mall-api/webChat/queryPayStatus/${orderNo}`
})


//新增收件人的接口
export const reqAddAddress = (data) => request({
    url: `/mall-api/userAddress/save`,
    method: 'post',
    data
});

//获取地址列表的数据
export const reqAddressList = () => request({
    url: `/mall-api/userAddress/findUserAddress`
})

//获取编辑这个用户信息接口
export const reqEditAddress = (id) => request({
    url: `/mall-api/userAddress/${id}`
})

//更新已有的地址
export const reqUpdateAddress = (data) => request({
    url: `/mall-api/userAddress/update`,
    method:'POST',
    data
})

//删除已有的用户信息
export const reqDeleteUser = (id)=>request({url:`/mall-api/userAddress/delete/${id}`});